
function submitComment() {
    var username = document.getElementById('username').value;
    var commentText = document.getElementById('comment').value;

    if (username && commentText) {
        var commentContainer = document.getElementById('commentsContainer');

        // 创建评论元素
        var commentElement = document.createElement('div');
        commentElement.className = 'comment';

        var commentContent = '<p><strong>' + username + ':</strong> ' + commentText + '</p>';
        commentElement.innerHTML = commentContent;

        // 将评论添加到评论容器中
        commentContainer.appendChild(commentElement);

        // 清空表单
        document.getElementById('commentForm').reset();
    } else {
        alert('请填写用户名和评论内容。');
    }
}
